<?php
/*
 * @Descripttion: 
 * @version: 
 * @Author: wanzhengxin
 * @Date: 2021-04-01 21:58:34
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2021-11-22 19:35:41
 */


namespace app\server\controller;

use app\index\controller\Base;
use app\server\model\Organization as OrganizationModel;

class Organization extends Base
{
    public function get(){
        $user = new OrganizationModel();
        $data=$this->request->param();
        $d = $user->get($data);
        if($d == null ){
            return 'false';
        }
        return $d;
    }
    
    //登录
    public function login(){
        $data = $this->request->param();
        $res = new OrganizationModel();
        if(empty($data) ){
            return 'fail,未定义参数tel';
        }else{
            $map =['tel'=>$data['tel'],'password'=>$data['password']];
            return $res->get($map);
        }
    }
    public function getOP(){
        $user = new OrganizationModel();
        $data=$this->request->param();
        $d = $user->where('address','like','%'.$data['address'].'%')
            ->where($data['field'],$data['op'],$data['value'])
            ->page($data['page'])
            ->limit(20)
            ->select();
        return $d;
    }
    //按名称搜索
    public function getByName(){
        $user = new OrganizationModel();
        $data=$this->request->param();
        $d = $user->where('name','like','%'.$data['name'].'%')
            ->where($data['field'],$data['op'],$data['value'])
            ->page($data['page'])
            ->limit(10)
            ->select();
        return $d;
    }
    public function getO(){
        $user = new OrganizationModel();
        $data=$this->request->param();
        $d = $user->where('address','like','%'.$data['address'].'%')
            ->where($data['field'],$data['op'],$data['value'])
            ->select();
        return $d;
    }
    public function update()
    {
        $data = $this->request->param();
        $res = new OrganizationModel();
        return $res->updateModel($data);
    }
    public function delete(){
        $data = $this->request->param();
        $res = new OrganizationModel();
        return $res->deleteModel($data);
    }
    public function save(){
        $res = new OrganizationModel();
        $data = $this->request->param();
        $d = $res->saveModel($data);
        return $d->o_id;
    }
    public function num(){
        $data = $this->request->param();
        $res =new OrganizationModel();
        return $res->where($data['field'],$data['op'],$data['value'])->count();
    }

}